# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
import hashlib,re,os,random
from storm.locals import *
from storm.expr import Sum,LeftJoin,Eq
from jinja2 import Template
from accost.shortcuts import *
from accost.utils.auth import *
from accost.handlers import *
from accost.paginator import (Paginator, InvalidPage, PageNotAnInteger, EmptyPage)
from werkzeug import cached_property
from werkzeug.exceptions import *
import simplejson as json
import logging
import pdb
import urllib
from code import interact
############################################################################
min_date = datetime(1900,1,1)
up_img_key = u'itisgoodyes'
page_count = 10
############################################################################
from chee import *
from chee.util import *
from chee.permission import *
from chee.handlers import *
from chee.fileHelper import FileHelper,ImageHelper
pathHelper = FileHelper()
imgHelper = ImageHelper()
def getGlobalTables():
    return []
def getGlobalCondition():
    return []
#############################################################################
from traceback import format_exc
def show_error(func):
    def _inner(request):
        try: return func(request)
        except: return Response(encodeJsonMsg(False, format_exc()))
    return _inner

def JsonMsg(result, type, data):
    resu = 'false'
    if result: resu = 'true'
    s = json.dumps({"result":resu,"type":type,"data":data})
    return Response(s)

